package com.mowh.multithreading.producer.consumer.table;

import java.util.concurrent.ArrayBlockingQueue;

/**
 * @author mowh1gd
 * @create 2023/11/21 11:18
 */
public class ArrayBlockingQueueTable extends ArrayBlockingQueue<String> {
    //ArrayBlockingQueue跟RawTable原理相同，当桌上蛋糕数量大于count时会阻塞。区别是不用关注索引位置。
    public ArrayBlockingQueueTable(int count) {
        super(count);
    }
    public void put(String cake) throws InterruptedException {
        System.out.println(Thread.currentThread().getName() + " puts " + cake);
        super.put(cake);
    }
    public String take() throws InterruptedException {
        String cake = super.take();
        System.out.println(Thread.currentThread().getName() + " takes " + cake);
        return cake;
    }
}
